package org.jeecg.modules.paycenter.channel.offline;

import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.paycenter.enums.PayChannelEnum;
import org.jeecg.modules.paycenter.service.BaseMemberService;
import org.jeecg.modules.paycenter.service.IMemberChannelService;
import org.jeecg.modules.wlhy.customer.entity.HyCustomer;
import org.jeecg.modules.wlhy.customerwallet.entity.HyCustomerWallet;
import org.jeecg.modules.wlhy.customerwallet.service.IHyCustomerWalletService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

@Service
public class OfflineMemberChannelService extends BaseMemberService implements IMemberChannelService {
    @Autowired
    private IHyCustomerWalletService customerWalletService;
    //region base
    @Override
    public PayChannelEnum getChannelEnum() {
        return PayChannelEnum.OFFLINE;
    }

    @Override
    public String getChannel() {
        return PayChannelEnum.OFFLINE.channelType;
    }

    @Override
    public boolean checkChannel() {
        return false;
    }
    //endregion

    //region 账户相关
    @Override
    public Result<?> getCustomerAvailBalStr(HyCustomer customer){
        HyCustomerWallet customerWallet = customerWalletService.getByCustomerId(customer.getId());
        if (customerWallet == null) {
            return Result.error("货主系统钱包不存在");
        }
        //可用余额
        BigDecimal amt = customerWallet.getAmt();
        return Result.OK(amt);
    }
    //endregion
}
